/*
 * MemoryManager.h
 *
 *  Created on: 02.04.2014
 *      Author: Nicolas
 */

#ifndef _SOLVER_MEMORYMANAGER_H
#define _SOLVER_MEMORYMANAGER_H

#include <vector>

namespace solver
{
	class MemoryBlock;
	class MemoryManager;
}


class solver::MemoryBlock
{
public:
	virtual ~MemoryBlock(void) = 0;
};


class solver::MemoryManager
{
	std::vector<MemoryBlock*> dataBlocks;
public:
	MemoryManager(void);
	virtual ~MemoryManager(void);

	template<typename T>
	T* allocate(void);
};


template<typename T>
T* solver::MemoryManager::allocate(void)
{
	T* t = new T();
	t->setMemoryManager(this);
	dataBlocks.push_back(dynamic_cast<MemoryBlock*> (t));
	return t;
}

#endif // _SOLVER_MEMORYMANAGER_H
